package com.itheima.test;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;

/*
无限发送
发送键盘录入的数据
 */
public class ClientDemo {

    public static void main(String[] args) throws Exception {
        //创建发送对象
        DatagramSocket ds = new DatagramSocket();
        //组织数据
        while (true) {
            String s = new Scanner(System.in).nextLine();
            if("886".equals(s)){
                break;
            }
            byte[] bytes =s.getBytes();
            DatagramPacket dp = new DatagramPacket(bytes, bytes.length, InetAddress.getByName("127.0.0.1"), 8888);
            // 发送
            ds.send(dp);
        }
        //释放资源
        //ds.close();
    }
}
